#ifndef HTTPPARSER_H
#define HTTPPARSER_H

#include "Socket.h"
#include <iostream>
#include <cstdlib>
#include <pthread.h>
#include <string>

class HttpRequest {
public:
    HttpRequest() {
        this->url = "";
        this->method = "";
    }
    std::string getUrl() const { return url; }
    std::string getMethod() const { return method; }
    void ParseSocket(TCPSocket *sock);
private:
    static std::string DecodeURL(const std::string & url);
    std::string url;
    std::string method;
};

class HttpError {
public:
    HttpError(int err) : errnum(err){
    }
    int getErr() const { return errnum; }
private:
    int errnum;
};

void SendHttpResponse(const std::string & path, const HttpRequest & req, TCPSocket *sock);

void SendHttpErrorResponse(const HttpError & err, TCPSocket *sock);
#endif
